package com.itany.cloud.service;

import com.itany.cloud.util.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/5/30 9:05
 * Version:1.0-SNAPSHOT
 * Description:
 */
@Service
// value:指定当前接口所调用的微服务是谁
// 其值是注册到Eureka注册中心中的微服务名
// 调用该微服务,表示访问了该微服务所在的服务器的根目录
// http://localhost:8001
//@FeignClient(value = "cloud-eureka-provider")
//@FeignClient(value = "cloud-eureka-provider",fallback = UserServiceFallback.class)
//@FeignClient(value = "cloud-eureka-zuul",fallback = UserServiceFallback.class)
@FeignClient(value = "cloud-eureka-zuul")
public interface UserService {

    // 通过调用微服务上的资源,实现对应的方法
    // 在当前service接口中,可以通过使用Handler中的注解进行远程服务的调用
    // 但是,当前并不是Handler
    // 因此,所有的Handler默认行为全部失效
    // 所有方法最终访问地址为:当前微服务地址+方法访问的具体地址

    @GetMapping("/v1/userService/users")
    public ResponseResult findAll();

    @GetMapping("/v1/userService/users/{id}")
    public ResponseResult findById(@PathVariable("id") Integer id);

    @PostMapping("/v1/userService/users")
    public ResponseResult addUser(@RequestParam("username") String username,@RequestParam("password") String password,@RequestParam("phone") String phone,@RequestParam("address") String address);

    @DeleteMapping("/v1/userService/users/{id}")
    public ResponseResult deleteUser(@PathVariable("id") Integer id);

    @PutMapping("/v1/userService/users")
    public ResponseResult modifyUser(@RequestParam("id") Integer id,@RequestParam("username") String username,@RequestParam("password") String password,@RequestParam("phone") String phone,@RequestParam("address") String address);


}
